//
//  MTRequirementsViewController.m
//  ShiShiBang
//
//  Created by songbaoqiang on 16/9/1.
//  Copyright © 2016年 motianjituan. All rights reserved.
//

#import "MTRequirementsViewController.h"

#import "MTLoginViewController.h"
#import "MTRegisterViewController.h"
#import "MTBottomView.h"
#import "RequireDetailController.h"
#import "MTChatViewController.h"
#import "MTRequireCell.h"
#import "MTRequireItem.h"
#import "UIViewController+JTNavigationExtension.h"
#import "NSObject+CCNSDictionary.h"
#import "RequireDataModel.h"
#import "RequireActionButton.h"

static NSString * const ID = @"cell";
@interface MTRequirementsViewController () 
@property (nonatomic, strong) NSMutableArray *itemArray;

@end
@implementation MTRequirementsViewController


-(void)viewWillAppear:(BOOL)animated{
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    [super viewWillAppear:YES];
    NSUserDefaults*pushJudge = [NSUserDefaults standardUserDefaults];
    if([[pushJudge objectForKey:@"push"]isEqualToString:@"push"]) {
        self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"02_03f@2x.png"] style:UIBarButtonItemStylePlain target:self action:@selector(rebackToRootViewAction)];
    }else{
        self.navigationItem.leftBarButtonItem=nil;
    }
}

- (void)rebackToRootViewAction {
    NSUserDefaults * pushJudge = [NSUserDefaults standardUserDefaults];
    [pushJudge setObject:@""forKey:@"push"];
    [pushJudge synchronize];//记得立即同步
    [self dismissViewControllerAnimated:YES completion:nil];
}


- (NSMutableArray *)itemArray {
    if (_itemArray == nil) {
        _itemArray = [NSMutableArray array];
    }
    return _itemArray;
}
- (void)viewDidLoad {

    [self initCollection];
    self.jt_fullScreenPopGestureEnabled = YES;
    self.tableView.rowHeight = 167 + 12;
    self.tableView.backgroundColor = UIColorFromRGB(0xf7f7f7);

    self.tableView.contentInset = UIEdgeInsetsMake(12, 0, 0, 0);
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([MTRequireCell class]) bundle:nil] forCellReuseIdentifier:ID];
    
}

#pragma mark ------点击跳转界面
-(void)chatClick {
    MTChatViewController *vc = [MTChatViewController shareChatViewController];
    [self.navigationController pushViewController:vc animated:YES];
    NSLog(@"two %@",vc);


}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section  {
    return 10;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
   
    MTRequireCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    // 设置数据
//    MTRequireItem *item = self.itemArray[indexPath.row];
//    cell.item = item;
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     [tableView deselectRowAtIndexPath:indexPath animated:YES];
    RequireDetailController *requireDetailCon = [[RequireDetailController alloc]init];
//    RequireDataModel *model = [NSObject ccObjectFromClass:[RequireDataModel class] dict:self.requireDataArray[rowNum]];
//    requireDetailCon.titleImageName = model.ItemIconArray[sortNum];
//    requireDetailCon.titleStr = titile;
//    requireDetailCon.actionType = actionType;
    [self.navigationController pushViewController:requireDetailCon animated:YES];
}



//- (void)viewWillAppear:(BOOL)animated {
//    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
//}

-(void)initCollection {
    NSMutableDictionary *attr = [NSMutableDictionary dictionary];
    attr[NSFontAttributeName] = [UIFont boldSystemFontOfSize:17];
    attr[NSForegroundColorAttributeName] = [UIColor whiteColor];
    [self.navigationController.navigationBar setTitleTextAttributes:attr];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:UIColorFromRGB(0x45c75a)]  forBarMetrics:UIBarMetricsDefault];
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithImage:[UIImage imageNamed:@"news"] highImage:[UIImage imageNamed:@"news_gray"] target:self action:@selector(chatClick)];
    self.navigationItem.title = @"有求管理";
}





@end
